package com.itheima.edu.info.manager.dao;

import com.itheima.edu.info.manager.domain.Student;

public class StudentDao {
    private static Student[] student = new Student[5];


    public boolean addStudent(Student s) {

        int index=-1;

        //循环遍历判断哪一个元素为null
        for (int i = 0; i < student.length; i++) {
            if(student[i]==null){
                index=i;
                break;
            }
        }

        //没有null元素返回false,有返回true,并将输入的值传给它
        if(index==-1){
            return false;
        }else{
            student[index] = s;
            return true;
        }
    }

    //返回数组索引
    public Student[] findAllStudent() {
        return student;
    }

    //删除第isExists的元素
    public void deleteStudentById(int isExists) {
        student[isExists]=null;
    }

    //修改第isExists的元素
    public void updateStudent(int isExists, Student s) {
        student[isExists]=s;
    }
}
